package o;

import android.animation.ObjectAnimator;
import android.animation.TimeInterpolator;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.content.res.Resources.Theme;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Outline;
import android.graphics.PorterDuff.Mode;
import android.graphics.Rect;
import android.graphics.drawable.Animatable;
import android.graphics.drawable.AnimationDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build.VERSION;
import android.util.AttributeSet;
import android.util.StateSet;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import java.io.IOException;
import o.ah.g;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;

public class ap extends ao {
    private static final String ˏ = ap.class.getSimpleName();
    private boolean ʼ;
    private a ˊ;
    private int ˋ;
    private j ˎ;
    private int ॱ;

    static class a extends c {
        dw<Long> ˋ;
        dz<Integer> ˎ;

        a(@Nullable a aVar, @NonNull ap apVar, @Nullable Resources resources) {
            super(aVar, apVar, resources);
            if (aVar != null) {
                this.ˋ = aVar.ˋ;
                this.ˎ = aVar.ˎ;
                return;
            }
            this.ˋ = new dw();
            this.ˎ = new dz();
        }

        void ˏ() {
            this.ˋ = this.ˋ.ˏ();
            this.ˎ = this.ˎ.ॱ();
        }

        int ˋ(int i, int i2, @NonNull Drawable drawable, boolean z) {
            int ˋ = super.ˋ(drawable);
            long ᐝ = ᐝ(i, i2);
            long j = 0;
            if (z) {
                j = 8589934592L;
            }
            this.ˋ.ˋ(ᐝ, Long.valueOf(((long) ˋ) | j));
            if (z) {
                this.ˋ.ˋ(ᐝ(i2, i), Long.valueOf(j | (((long) ˋ) | 4294967296L)));
            }
            return ˋ;
        }

        int ˊ(@NonNull int[] iArr, @NonNull Drawable drawable, int i) {
            int ˏ = super.ˏ(iArr, drawable);
            this.ˎ.ˋ(ˏ, Integer.valueOf(i));
            return ˏ;
        }

        int ˊ(@NonNull int[] iArr) {
            int ˋ = super.ˋ(iArr);
            return ˋ >= 0 ? ˋ : super.ˋ(StateSet.WILD_CARD);
        }

        int ॱ(int i) {
            return i < 0 ? 0 : ((Integer) this.ˎ.ॱ(i, Integer.valueOf(0))).intValue();
        }

        int ॱ(int i, int i2) {
            return (int) ((Long) this.ˋ.ˊ(ᐝ(i, i2), Long.valueOf(-1))).longValue();
        }

        boolean ˎ(int i, int i2) {
            return (((Long) this.ˋ.ˊ(ᐝ(i, i2), Long.valueOf(-1))).longValue() & 4294967296L) != 0;
        }

        boolean ˏ(int i, int i2) {
            return (((Long) this.ˋ.ˊ(ᐝ(i, i2), Long.valueOf(-1))).longValue() & 8589934592L) != 0;
        }

        @NonNull
        public Drawable newDrawable() {
            return new ap(this, null);
        }

        @NonNull
        public Drawable newDrawable(Resources resources) {
            return new ap(this, resources);
        }

        private static long ᐝ(int i, int i2) {
            return (((long) i) << 32) | ((long) i2);
        }
    }

    static abstract class j {
        public abstract void ˊ();

        public abstract void ॱ();

        private j() {
        }

        public void ˋ() {
        }

        public boolean ˎ() {
            return false;
        }
    }

    static class b extends j {
        private final Animatable ˏ;

        b(Animatable animatable) {
            super();
            this.ˏ = animatable;
        }

        public void ˊ() {
            this.ˏ.start();
        }

        public void ॱ() {
            this.ˏ.stop();
        }
    }

    static class c extends j {
        private final ot ˊ;

        c(ot otVar) {
            super();
            this.ˊ = otVar;
        }

        public void ˊ() {
            this.ˊ.start();
        }

        public void ॱ() {
            this.ˊ.stop();
        }
    }

    static class d extends j {
        private final boolean ˋ;
        private final ObjectAnimator ˎ;

        d(AnimationDrawable animationDrawable, boolean z, boolean z2) {
            super();
            int numberOfFrames = animationDrawable.getNumberOfFrames();
            int i = z ? numberOfFrames - 1 : 0;
            int i2 = z ? 0 : numberOfFrames - 1;
            TimeInterpolator eVar = new e(animationDrawable, z);
            ObjectAnimator ofInt = ObjectAnimator.ofInt(animationDrawable, "currentIndex", new int[]{i, i2});
            if (VERSION.SDK_INT >= 18) {
                ofInt.setAutoCancel(true);
            }
            ofInt.setDuration((long) eVar.ˏ());
            ofInt.setInterpolator(eVar);
            this.ˋ = z2;
            this.ˎ = ofInt;
        }

        public boolean ˎ() {
            return this.ˋ;
        }

        public void ˊ() {
            this.ˎ.start();
        }

        public void ˋ() {
            this.ˎ.reverse();
        }

        public void ॱ() {
            this.ˎ.cancel();
        }
    }

    static class e implements TimeInterpolator {
        private int[] ˊ;
        private int ˏ;
        private int ॱ;

        e(AnimationDrawable animationDrawable, boolean z) {
            ˎ(animationDrawable, z);
        }

        int ˎ(AnimationDrawable animationDrawable, boolean z) {
            int i = 0;
            int numberOfFrames = animationDrawable.getNumberOfFrames();
            this.ॱ = numberOfFrames;
            if (this.ˊ == null || this.ˊ.length < numberOfFrames) {
                this.ˊ = new int[numberOfFrames];
            }
            int[] iArr = this.ˊ;
            int i2 = 0;
            while (i < numberOfFrames) {
                int i3;
                if (z) {
                    i3 = (numberOfFrames - i) - 1;
                } else {
                    i3 = i;
                }
                i3 = animationDrawable.getDuration(i3);
                iArr[i] = i3;
                i++;
                i2 = i3 + i2;
            }
            this.ˏ = i2;
            return i2;
        }

        int ˏ() {
            return this.ˏ;
        }

        public float getInterpolation(float f) {
            float f2;
            int i = (int) ((((float) this.ˏ) * f) + 0.5f);
            int i2 = this.ॱ;
            int[] iArr = this.ˊ;
            int i3 = i;
            i = 0;
            while (i < i2 && i3 >= iArr[i]) {
                int i4 = i3 - iArr[i];
                i++;
                i3 = i4;
            }
            if (i < i2) {
                f2 = ((float) i3) / ((float) this.ˏ);
            } else {
                f2 = 0.0f;
            }
            return f2 + (((float) i) / ((float) i2));
        }
    }

    @RequiresApi(21)
    public /* bridge */ /* synthetic */ void applyTheme(@NonNull Theme theme) {
        super.applyTheme(theme);
    }

    @RequiresApi(21)
    public /* bridge */ /* synthetic */ boolean canApplyTheme() {
        return super.canApplyTheme();
    }

    public /* bridge */ /* synthetic */ void draw(@NonNull Canvas canvas) {
        super.draw(canvas);
    }

    public /* bridge */ /* synthetic */ int getAlpha() {
        return super.getAlpha();
    }

    public /* bridge */ /* synthetic */ int getChangingConfigurations() {
        return super.getChangingConfigurations();
    }

    @NonNull
    public /* bridge */ /* synthetic */ Drawable getCurrent() {
        return super.getCurrent();
    }

    public /* bridge */ /* synthetic */ void getHotspotBounds(@NonNull Rect rect) {
        super.getHotspotBounds(rect);
    }

    public /* bridge */ /* synthetic */ int getIntrinsicHeight() {
        return super.getIntrinsicHeight();
    }

    public /* bridge */ /* synthetic */ int getIntrinsicWidth() {
        return super.getIntrinsicWidth();
    }

    public /* bridge */ /* synthetic */ int getMinimumHeight() {
        return super.getMinimumHeight();
    }

    public /* bridge */ /* synthetic */ int getMinimumWidth() {
        return super.getMinimumWidth();
    }

    public /* bridge */ /* synthetic */ int getOpacity() {
        return super.getOpacity();
    }

    @RequiresApi(21)
    public /* bridge */ /* synthetic */ void getOutline(@NonNull Outline outline) {
        super.getOutline(outline);
    }

    public /* bridge */ /* synthetic */ boolean getPadding(@NonNull Rect rect) {
        return super.getPadding(rect);
    }

    public /* bridge */ /* synthetic */ void invalidateDrawable(@NonNull Drawable drawable) {
        super.invalidateDrawable(drawable);
    }

    public /* bridge */ /* synthetic */ boolean isAutoMirrored() {
        return super.isAutoMirrored();
    }

    public /* bridge */ /* synthetic */ boolean onLayoutDirectionChanged(int i) {
        return super.onLayoutDirectionChanged(i);
    }

    public /* bridge */ /* synthetic */ void scheduleDrawable(@NonNull Drawable drawable, @NonNull Runnable runnable, long j) {
        super.scheduleDrawable(drawable, runnable, j);
    }

    public /* bridge */ /* synthetic */ void setAlpha(int i) {
        super.setAlpha(i);
    }

    public /* bridge */ /* synthetic */ void setAutoMirrored(boolean z) {
        super.setAutoMirrored(z);
    }

    public /* bridge */ /* synthetic */ void setColorFilter(ColorFilter colorFilter) {
        super.setColorFilter(colorFilter);
    }

    public /* bridge */ /* synthetic */ void setDither(boolean z) {
        super.setDither(z);
    }

    public /* bridge */ /* synthetic */ void setHotspot(float f, float f2) {
        super.setHotspot(f, f2);
    }

    public /* bridge */ /* synthetic */ void setHotspotBounds(int i, int i2, int i3, int i4) {
        super.setHotspotBounds(i, i2, i3, i4);
    }

    public /* bridge */ /* synthetic */ void setTintList(ColorStateList colorStateList) {
        super.setTintList(colorStateList);
    }

    public /* bridge */ /* synthetic */ void setTintMode(@NonNull Mode mode) {
        super.setTintMode(mode);
    }

    public /* bridge */ /* synthetic */ void unscheduleDrawable(@NonNull Drawable drawable, @NonNull Runnable runnable) {
        super.unscheduleDrawable(drawable, runnable);
    }

    /* synthetic */ c ˋ() {
        return ˊ();
    }

    /* synthetic */ d ˎ() {
        return ˊ();
    }

    public ap() {
        this(null, null);
    }

    ap(@Nullable a aVar, @Nullable Resources resources) {
        super(null);
        this.ॱ = -1;
        this.ˋ = -1;
        ॱ(new a(aVar, this, resources));
        onStateChange(getState());
        jumpToCurrentState();
    }

    public static ap ˊ(@NonNull Context context, @NonNull Resources resources, @NonNull XmlPullParser xmlPullParser, @NonNull AttributeSet attributeSet, @Nullable Theme theme) throws IOException, XmlPullParserException {
        String name = xmlPullParser.getName();
        if (name.equals("animated-selector")) {
            ap apVar = new ap();
            apVar.ˋ(context, resources, xmlPullParser, attributeSet, theme);
            return apVar;
        }
        throw new XmlPullParserException(xmlPullParser.getPositionDescription() + ": invalid animated-selector tag " + name);
    }

    public void ˋ(@NonNull Context context, @NonNull Resources resources, @NonNull XmlPullParser xmlPullParser, @NonNull AttributeSet attributeSet, @Nullable Theme theme) throws XmlPullParserException, IOException {
        TypedArray ˎ = fx.ˎ(resources, theme, attributeSet, g.ॱʻ);
        setVisible(ˎ.getBoolean(g.ॱʽ, true), true);
        ˋ(ˎ);
        ˎ(resources);
        ˎ.recycle();
        ˎ(context, resources, xmlPullParser, attributeSet, theme);
        ˏ();
    }

    public boolean setVisible(boolean z, boolean z2) {
        boolean visible = super.setVisible(z, z2);
        if (this.ˎ != null && (visible || z2)) {
            if (z) {
                this.ˎ.ˊ();
            } else {
                jumpToCurrentState();
            }
        }
        return visible;
    }

    public boolean isStateful() {
        return true;
    }

    public void jumpToCurrentState() {
        super.jumpToCurrentState();
        if (this.ˎ != null) {
            this.ˎ.ॱ();
            this.ˎ = null;
            ˎ(this.ॱ);
            this.ॱ = -1;
            this.ˋ = -1;
        }
    }

    protected boolean onStateChange(int[] iArr) {
        int ˊ = this.ˊ.ˊ(iArr);
        boolean z = ˊ != ॱ() && (ॱ(ˊ) || ˎ(ˊ));
        Drawable current = getCurrent();
        if (current != null) {
            return z | current.setState(iArr);
        }
        return z;
    }

    private boolean ॱ(int i) {
        int ॱ;
        j jVar = this.ˎ;
        if (jVar == null) {
            ॱ = ॱ();
        } else if (i == this.ॱ) {
            return true;
        } else {
            if (i == this.ˋ && jVar.ˎ()) {
                jVar.ˋ();
                this.ॱ = this.ˋ;
                this.ˋ = i;
                return true;
            }
            int i2 = this.ॱ;
            jVar.ॱ();
            ॱ = i2;
        }
        this.ˎ = null;
        this.ˋ = -1;
        this.ॱ = -1;
        a aVar = this.ˊ;
        int ॱ2 = aVar.ॱ(ॱ);
        int ॱ3 = aVar.ॱ(i);
        if (ॱ3 == 0 || ॱ2 == 0) {
            return false;
        }
        i2 = aVar.ॱ(ॱ2, ॱ3);
        if (i2 < 0) {
            return false;
        }
        j dVar;
        boolean ˏ = aVar.ˏ(ॱ2, ॱ3);
        ˎ(i2);
        Drawable current = getCurrent();
        if (current instanceof AnimationDrawable) {
            dVar = new d((AnimationDrawable) current, aVar.ˎ(ॱ2, ॱ3), ˏ);
        } else if (current instanceof ot) {
            dVar = new c((ot) current);
        } else if (!(current instanceof Animatable)) {
            return false;
        } else {
            dVar = new b((Animatable) current);
        }
        dVar.ˊ();
        this.ˎ = dVar;
        this.ˋ = ॱ;
        this.ॱ = i;
        return true;
    }

    private void ˋ(TypedArray typedArray) {
        a aVar = this.ˊ;
        if (VERSION.SDK_INT >= 21) {
            aVar.ʽ |= typedArray.getChangingConfigurations();
        }
        aVar.ˎ(typedArray.getBoolean(g.ᐨ, aVar.ˋॱ));
        aVar.ˋ(typedArray.getBoolean(g.ᐝˊ, aVar.ॱˊ));
        aVar.ˋ(typedArray.getInt(g.ᐧ, aVar.ˊˋ));
        aVar.ˎ(typedArray.getInt(g.ᐝᐝ, aVar.ˊˊ));
        setDither(typedArray.getBoolean(g.ـ, aVar.ˋˊ));
    }

    private void ˏ() {
        onStateChange(getState());
    }

    private void ˎ(@NonNull Context context, @NonNull Resources resources, @NonNull XmlPullParser xmlPullParser, @NonNull AttributeSet attributeSet, @Nullable Theme theme) throws XmlPullParserException, IOException {
        int depth = xmlPullParser.getDepth() + 1;
        while (true) {
            int next = xmlPullParser.next();
            if (next != 1) {
                int depth2 = xmlPullParser.getDepth();
                if (depth2 < depth && next == 3) {
                    return;
                }
                if (next == 2 && depth2 <= depth) {
                    if (xmlPullParser.getName().equals("item")) {
                        ॱ(context, resources, xmlPullParser, attributeSet, theme);
                    } else if (xmlPullParser.getName().equals("transition")) {
                        ˏ(context, resources, xmlPullParser, attributeSet, theme);
                    }
                }
            } else {
                return;
            }
        }
    }

    private int ˏ(@NonNull Context context, @NonNull Resources resources, @NonNull XmlPullParser xmlPullParser, @NonNull AttributeSet attributeSet, @Nullable Theme theme) throws XmlPullParserException, IOException {
        TypedArray ˎ = fx.ˎ(resources, theme, attributeSet, g.ᶥ);
        int resourceId = ˎ.getResourceId(g.ﾟ, -1);
        int resourceId2 = ˎ.getResourceId(g.ㆍ, -1);
        Drawable drawable = null;
        int resourceId3 = ˎ.getResourceId(g.ꜞ, -1);
        if (resourceId3 > 0) {
            drawable = ar.ˋ(context, resourceId3);
        }
        boolean z = ˎ.getBoolean(g.ꞌ, false);
        ˎ.recycle();
        if (drawable == null) {
            int next;
            do {
                next = xmlPullParser.next();
            } while (next == 4);
            if (next != 2) {
                throw new XmlPullParserException(xmlPullParser.getPositionDescription() + ": <transition> tag requires a 'drawable' attribute or child tag defining a drawable");
            } else if (xmlPullParser.getName().equals("animated-vector")) {
                drawable = ot.ˊ(context, resources, xmlPullParser, attributeSet, theme);
            } else if (VERSION.SDK_INT >= 21) {
                drawable = Drawable.createFromXmlInner(resources, xmlPullParser, attributeSet, theme);
            } else {
                drawable = Drawable.createFromXmlInner(resources, xmlPullParser, attributeSet);
            }
        }
        if (drawable == null) {
            throw new XmlPullParserException(xmlPullParser.getPositionDescription() + ": <transition> tag requires a 'drawable' attribute or child tag defining a drawable");
        } else if (resourceId != -1 && resourceId2 != -1) {
            return this.ˊ.ˋ(resourceId, resourceId2, drawable, z);
        } else {
            throw new XmlPullParserException(xmlPullParser.getPositionDescription() + ": <transition> tag requires 'fromId' & 'toId' attributes");
        }
    }

    private int ॱ(@NonNull Context context, @NonNull Resources resources, @NonNull XmlPullParser xmlPullParser, @NonNull AttributeSet attributeSet, @Nullable Theme theme) throws XmlPullParserException, IOException {
        TypedArray ˎ = fx.ˎ(resources, theme, attributeSet, g.ᐝˋ);
        int resourceId = ˎ.getResourceId(g.ꓸ, 0);
        Drawable drawable = null;
        int resourceId2 = ˎ.getResourceId(g.ꜟ, -1);
        if (resourceId2 > 0) {
            drawable = ar.ˋ(context, resourceId2);
        }
        ˎ.recycle();
        int[] ˏ = ˏ(attributeSet);
        if (drawable == null) {
            int next;
            do {
                next = xmlPullParser.next();
            } while (next == 4);
            if (next != 2) {
                throw new XmlPullParserException(xmlPullParser.getPositionDescription() + ": <item> tag requires a 'drawable' attribute or child tag defining a drawable");
            } else if (xmlPullParser.getName().equals("vector")) {
                drawable = ov.ॱ(resources, xmlPullParser, attributeSet, theme);
            } else if (VERSION.SDK_INT >= 21) {
                drawable = Drawable.createFromXmlInner(resources, xmlPullParser, attributeSet, theme);
            } else {
                drawable = Drawable.createFromXmlInner(resources, xmlPullParser, attributeSet);
            }
        }
        if (drawable != null) {
            return this.ˊ.ˊ(ˏ, drawable, resourceId);
        }
        throw new XmlPullParserException(xmlPullParser.getPositionDescription() + ": <item> tag requires a 'drawable' attribute or child tag defining a drawable");
    }

    public Drawable mutate() {
        if (!this.ʼ && super.mutate() == this) {
            this.ˊ.ˏ();
            this.ʼ = true;
        }
        return this;
    }

    a ˊ() {
        return new a(this.ˊ, this, null);
    }

    protected void ॱ(@NonNull d dVar) {
        super.ॱ(dVar);
        if (dVar instanceof a) {
            this.ˊ = (a) dVar;
        }
    }
}
